﻿/*
 * Module Name: Node.cs
 * 
 * Purpose: This is a Class for handeling the tree nodes
 * 
 * Created by: Chris Tisdale
 */

using System;
using System.Collections.Generic;
using System.Text;

namespace Common_Code.Trees
{
    class Node<T> where T : IComparable
    {
        /*
         * These are the private variables used throught the function
         */
        private Node<T> leftNode;
        private Node<T> rightNode;
        private int height;
        private T item;

        /*
         * Name: Node
         * 
         * Parameters: Node<T> left
         *             Node<T> right
         *             T item
         * 
         * Returns: A Node Object
         * 
         * Purpose: Creates a Node
         */
        public Node(Node<T> left, Node<T> right, T item)
        {
            this.height = 1;
            this.leftNode = left;
            this.rightNode = right;
            this.item = item;
        }

        /*
         * Name: Node
         * 
         * Parameters: T item
         * 
         * Returns: A Node Object
         * 
         * Purpose: Creates a Node
         */
        public Node(T item)
        {
            this.height = 0;
            this.leftNode = null;
            this.rightNode = null;
            this.item = item;
        }

        /*
         * Name: SetLeftNode
         * 
         * Parameters: Node<T> left
         * 
         * Returns: None
         * 
         * Purpose: This sets the left child node to left
         */
        public void SetLeftNode(Node<T> left)
        {
            this.leftNode = left;
        }

        /*
         * Name: SetRightNode
         * 
         * Parameters: Node<T> right
         * 
         * Returns: None
         * 
         * Purpose: This sets the right child node to right
         */
        public void SetRightNode(Node<T> right)
        {
            this.rightNode = right;
        }

        /*
         * Name: SetHeight
         * 
         * Parameters: int height
         * 
         * Returns: None
         * 
         * Purpose: This sets the height to height
         */
        public void SetHeight(int height)
        {
            this.height = height;
        }

        /*
         * Name: SetItem
         * 
         * Parameters: int height
         * 
         * Returns: None
         * 
         * Purpose: This sets the height to height
         */
        public void SetItem(T item)
        {
            this.item = item;
        }

        /*
         * Name: GetLeftNode
         * 
         * Parameters: None
         * 
         * Returns: Node<T>
         * 
         * Purpose: This gets the left child of this node
         */
        public Node<T> GetLeftNode()
        {
            return this.leftNode;
        }

        /*
         * Name: GetRightNode
         * 
         * Parameters: None
         * 
         * Returns: Node<T>
         * 
         * Purpose: This gets the right child of this node
         */
        public Node<T> GetRightNode()
        {
            return this.rightNode;
        }

        /*
         * Name: GetHeight
         * 
         * Parameters: None
         * 
         * Returns: int
         * 
         * Purpose: This gets the height of this node
         */
        public int GetHeight()
        {
            return this.height;
        }

        /*
         * Name: GetItem
         * 
         * Parameters: None
         * 
         * Returns: T
         * 
         * Purpose: This gets the object of the node
         */
        public T GetItem()
        {
            return this.item;
        }
    }
}
